import { debounce } from 'common/utils'
import BackTop from "components/content/backTop/BackTop"

export const itemListenerMixin = {
  data () {
    return {
      itemImgListener: null,
      newrefresh: null
    }
  },
  mounted () {
    // 监听item中图片加载完成
    this.newrefresh = debounce(this.$refs.scroll.refresh, 500)
    // 对监听事件的保存
    this.itemImgListener = () => {
      this.newrefresh()
    }
    this.$bus.$on('itemImageLoad', this.itemImgListener)
  }
}

export const backTopMixin = {
  components: {
    BackTop
  },
  data () {
    return {
      isShowBackTop: false
    }
  },
  methods: {
    // 回到顶部事件
    backClick () {
      this.$refs.scroll.scrollTo(0, 0, 600);
    },
  },
}